<?php
ob_start();
session_start();
//error_reporting(0); //hide error or warning
try{
    
    $file=fopen("setting.txt","r");

    $dynamic_url = fgets($file);
    $protocol="http://";
    $static_url="/ServiceRest.svc";
   
    //set server connection
    $url = $protocol.$dynamic_url.$static_url;
   // echo$url; 
   
    //print_r($url); break;
    $ctx = stream_context_create(array('http' => array('timeout' => 30))); 
    $client = true;// @file_get_contents($url,0,$ctx);
    
    if($client){
    
    $SESSION['button']=true;
    ?>
    <div class="server"><label>Server :</label><label class="green"> Online</label></div>
    <!--<div onclick=" popup('esa/post.php'); hide_div('maincontent');"><img src="esa/img/icon_up.png" /></div> -->
    <div class="spacer"> </div>
    <script>EnableButton();</script>
    
    <?php  
    }else{
        
    $SESSION['button']=false;
    //echo $e->getMessage(); 
    ?>
    <div class="server" ><label>Server :</label><label class="red"> Offline</label></div>
    <!--<div onclick=" popup('esa/post.php'); hide_div('maincontent'); "><img src="esa/img/icon_up.png" /></div> -->
    <div class="spacer"> </div> 
    <script>DisableButton();</script>
    <?php
        
        
    }
    
}catch(Exception $e){     
 echo$e;
}    
?>